package csu.ssd.student;

import csu.ssd.student.Dao.studentDao;
import csu.ssd.student.vo.Student;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Button;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.cell.PropertyValueFactory;

import java.net.URL;
import java.util.List;
import java.util.ResourceBundle;
import csu.ssd.student.Test;
import javafx.stage.Stage;

public class danController implements Initializable {

    @FXML
    private TableView<Student> dan;

    @FXML
    private Button da;

    @FXML
    private TableColumn<Student, String> kemu;

    @FXML
    private TableColumn<Student, Integer> last;

    @FXML
    private TableColumn<Student, Integer> paper;

    @FXML
    private TableColumn<Integer, Integer> hao;

    @FXML
    private TableColumn<Student, Integer> pingshi;

    @FXML
    private TableColumn<Student, Integer> jige;

    @FXML
    private TableColumn<Student, Integer> fen;

    private ObservableList<Student> RoleData = FXCollections.observableArrayList();

    @FXML
    void dayin(ActionEvent event) {
        studentDao m = new studentDao();
        List<Student> list = m.getRole();
        int mm = 1;
        Test mmm=new Test();
        String[] jh={"编号","学号","姓名","科目","考试成绩","是否及格","最终成绩","平时成绩","学期","学分"};
        mmm.export(list,jh);
    }
    @Override
    public void initialize(URL location, ResourceBundle resources) {

        studentDao m = new studentDao();
        List<Student> list = m.getRole();
        int mm = 1;

        for (Student f : list) {


            RoleData.add(f);

            //finishtowait.setCellValueFactory(cellData ->cellData.getValue().cb.getCheckBox());
            kemu.setCellValueFactory(new PropertyValueFactory<>("kemu"));
            last.setCellValueFactory(new PropertyValueFactory<>("last"));
            fen.setCellValueFactory(new PropertyValueFactory<>("fen"));
            jige.setCellValueFactory(new PropertyValueFactory<>("jige"));
            paper.setCellValueFactory(new PropertyValueFactory<>("paper"));
            pingshi.setCellValueFactory(new PropertyValueFactory<>("pingshi"));
            //  finishren.setCellValueFactory(new PropertyValueFactory<>("name"));

            dan.setItems(RoleData);
            //Test mmm=new Test();
            //String[] jh={"科目","最终成绩","sdgi","gsirej","isgo"};



        }
    }
}
